﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace BackOffice
{
    // Nota: para obtener instrucciones sobre cómo habilitar el modo clásico de IIS6 o IIS7, 
    // visite http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            // account
            routes.MapRoute(null, "Account/HandleLogin", new { controller = "Account", action = "HandleLogin" });
            routes.MapRoute(null, "Account/LogOff", new { controller = "Account", action = "LogOff" });

            routes.MapRoute(null, "Account/Index", new { controller = "Account", action = "Index" });
            routes.MapRoute(null, "Account/EndSession/{Returnurl}", new { controller = "Account", action = "EndSession", ReturnUrl = UrlParameter.Optional });

            // Casos
            routes.MapRoute(null, "Casos/Menu", new { controller = "Casos", action = "PartialMenu" });
            routes.MapRoute(null, "Casos", new { controller = "Casos", action = "Index" });
            routes.MapRoute(null, "Casos/Lista", new { controller = "Casos", action = "ListCasos" });
            routes.MapRoute(null, "Casos/caso/{id}", new { controller = "Casos", action = "Caso" });
            routes.MapRoute(null, "Casos/Nuevo", new { controller = "Casos", action = "NuevoCaso" });
            routes.MapRoute(null, "Casos/Rotativo/{idCaso}", new { controller = "Casos", action = "Rotativo" });
            
            routes.MapRoute(null, "Casos/Insert", new { controller = "Casos", action = "InsertCaso" });
            routes.MapRoute(null, "Casos/Update", new { controller = "Casos", action = "UpdateCaso" });
            routes.MapRoute(null, "Casos/Eliminar", new { controller = "Casos", action = "DeleteCaso" });

            routes.MapRoute(null, "Casos/Galeria/InsertImagen", new { controller = "Casos", action = "InsertImagenGaleria" });
            routes.MapRoute(null, "Casos/Galeria/EliminarImagen", new { controller = "Casos", action = "DeleteImagenRotativo" });
            routes.MapRoute(null, "Casos/Galeria/UpdateOrden", new { controller = "Casos", action = "UpdateOrden" });

            // Galeria del Home
            routes.MapRoute(null, "GaleriaHome/Menu", new { controller = "GaleriaHome", action = "PartialMenu" });
            routes.MapRoute(null, "GaleriaHome", new { controller = "GaleriaHome", action = "Index" });

            routes.MapRoute(null, "GaleriaHome/InsertImagen", new { controller = "GaleriaHome", action = "InsertImage" });
            routes.MapRoute(null, "GaleriaHome/EliminarImagen", new { controller = "GaleriaHome", action = "DeleteImagen" });
            routes.MapRoute(null, "GaleriaHome/UpdateOrden", new { controller = "GaleriaHome", action = "UpdateOrden" });

            // Clientes
            routes.MapRoute(null, "Clientes/Menu", new { controller = "Clientes", action = "PartialMenu" });
            routes.MapRoute(null, "Clientes", new { controller = "Clientes", action = "Index" });
            routes.MapRoute(null, "Clientes/Lista", new { controller = "Clientes", action = "ListClientes" });
            routes.MapRoute(null, "Clientes/Cliente/Nuevo", new { controller = "Clientes", action = "NuevoCliente" });
            routes.MapRoute(null, "Clientes/Cliente/{idCliente}", new { controller = "Clientes", action = "Cliente" });            

            routes.MapRoute(null, "Clientes/Insert", new { controller = "Clientes", action = "InsertCliente" });
            routes.MapRoute(null, "Clientes/Eliminar", new { controller = "Clientes", action = "DeleteCliente" });
            routes.MapRoute(null, "Clientes/Update", new { controller = "Clientes", action = "UpdateCliente" });

            // Empleados
            routes.MapRoute(null, "Empleados/Menu", new { controller = "Empleado", action = "PartialMenu" });
            routes.MapRoute(null, "Empleados", new { controller = "Empleado", action = "Index" });
            routes.MapRoute(null, "Empleados/Lista", new { controller = "Empleado", action = "ListEmpleados" });
            routes.MapRoute(null, "Empleados/Empleado/Nuevo", new { controller = "Empleado", action = "NuevoEmpleado" });
            routes.MapRoute(null, "Empleados/Empleado/{idEmpleado}", new { controller = "Empleado", action = "Empleado" });

            routes.MapRoute(null, "Empleados/Insert", new { controller = "Empleado", action = "InsertEmpleado" });
            routes.MapRoute(null, "Empleados/Eliminar", new { controller = "Empleado", action = "DeleteEmpleado" });
            routes.MapRoute(null, "Empleados/Update", new { controller = "Empleado", action = "UpdateEmpleado" });

            // Imagenes
            routes.MapRoute(null, "Imagen/{idImagen}", new { controller = "Imagen", action = "GetImagen" });
            //Home
            routes.MapRoute(null, "", new { controller = "Home", action = "Index" });


           /* routes.MapRoute(
                "Default", // Nombre de ruta
                "{controller}/{action}/{id}", // URL con parámetros
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Valores predeterminados de parámetro
            );*/

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}